class ToastsController < ApplicationController
  # GET /toasts
  # GET /toasts.xml
  def index
    @toasts = Toast.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @toasts }
    end
  end

  # GET /toasts/1
  # GET /toasts/1.xml
  def show
    @toast = Toast.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @toast }
    end
  end

  # GET /toasts/new
  # GET /toasts/new.xml
  def new
    @toast = Toast.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @toast }
    end
  end

  # GET /toasts/1/edit
  def edit
    @toast = Toast.find(params[:id])
  end

  # POST /toasts
  # POST /toasts.xml
  def create
    @toast = Toast.new(params[:toast])

    respond_to do |format|
      if @toast.save
        flash[:notice] = 'Toast was successfully created.'
        format.html { redirect_to(@toast) }
        format.xml  { render :xml => @toast, :status => :created, :location => @toast }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @toast.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /toasts/1
  # PUT /toasts/1.xml
  def update
    @toast = Toast.find(params[:id])

    respond_to do |format|
      if @toast.update_attributes(params[:toast])
        flash[:notice] = 'Toast was successfully updated.'
        format.html { redirect_to(@toast) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @toast.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /toasts/1
  # DELETE /toasts/1.xml
  def destroy
    @toast = Toast.find(params[:id])
    @toast.destroy

    respond_to do |format|
      format.html { redirect_to(toasts_url) }
      format.xml  { head :ok }
    end
  end
end
